package service;

import entity.User;
import entity.User_1;
import uitl.Reslut_1;

public class UserManagement_1 {
    /**
     * 逻辑类
     */
    private User_1[] user_1 = {};
    private final int SHUZU = 10;

    private int size = 0;

    //自己new自己给长度
    private void UserManagement(){
        this.user_1 = new User_1[SHUZU];
    }

    //添加
    public Reslut_1 adduser(User_1 user_1){
        for (int i = 0; i < this.size; i++) {
            User_1 u = this.user_1[i];
            if (u.getUserName().equals(user_1.getUserName())){
                return new Reslut_1("用户名重复");
            }
        }
        this.user_1[size++] = user_1;
        return Reslut_1.$true();
    }

    //查询密码和用户名是否为空
    private Reslut_1 login(User_1 user_1){
        for (int i = 0; i < this.size; i++) {
            User_1 u = this.user_1[i];
            if (u.getUserPassword().equals(user_1.getUserPassword()) && u.getUserName().equals(user_1.getUserName())){
                return Reslut_1.$true();
            }
        }
        return new Reslut_1("用户名或密码错误！");
    }
}
